package com.zd.commodity.productMng.biz.impl;

import java.util.HashSet;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zd.commodity.biz.impl.BaseBiz;
import com.zd.commodity.brandMng.dao.IBrandShowDao;
import com.zd.commodity.brandMng.entity.BrandShow;
import com.zd.commodity.productMng.biz.IProductSeriesBiz;
import com.zd.commodity.productMng.dao.IProductIntroductionDao;
import com.zd.commodity.productMng.dao.IProductSeriesDao;
import com.zd.commodity.productMng.entity.ProductIntroduction;
import com.zd.commodity.productMng.entity.ProductSeries;
import com.zd.commodity.product_pic.dao.IProductPicDao;
import com.zd.commodity.product_pic.entity.ProductPic;

@Service("ProductSeriesBiz")
public class ProductSeriesBizImpl extends BaseBiz<ProductSeries> implements IProductSeriesBiz {
	private IProductSeriesDao productSeriesDao;
	@Autowired
	private IProductPicDao productPicDao;
	
	@Override
	public void updateProductSeries(ProductSeries productSeries, long[] picIds) {
		//先删除所有图片
		productSeries.setProductPicList(new HashSet<ProductPic>());
		for (long picId : picIds) {
			ProductPic productPic = productPicDao.get(picId);
			productSeries.getProductPicList().add(productPic);
		}
		productSeriesDao.update(productSeries);
	}
	
	@Override
	public void addProductSeries(ProductSeries productSeries, long[] picIds) {
		for (long picId : picIds) {
			ProductPic productPic = productPicDao.get(picId);
			if(productPic!=null){
				productSeries.getProductPicList().add(productPic);
			}
		}
		productSeriesDao.add(productSeries);
	}

	public IProductSeriesDao getProductSeriesDao() {
		return productSeriesDao;
	}
    
	@Autowired
	public void setProductSeriesDao(IProductSeriesDao productSeriesDao) {
		this.productSeriesDao = productSeriesDao;
	    this.setBaseDao(productSeriesDao);
	}


	
}
